import 'package:duqin/components/avatar_role_name.dart';
import 'package:duqin/components/comment_like_read.dart';
import 'package:duqin/config/app_colors.dart';
import 'package:duqin/models/song_model.dart';
import 'package:flutter/material.dart';

class SongCard extends StatelessWidget {
  final SongInfo info;
  const SongCard({Key? key, required this.info}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      height: 105,
      width: MediaQuery.of(context).size.width,
      color: Colors.white,
      child: Padding(
        padding: EdgeInsets.all(18),
        child: Row(children: [
          _songImg(),
          SizedBox(
            width: 9,
          ),
          Expanded(child: _songContent())
        ]),
      ),
    );
  }

  _songImg() {
    return SizedBox(
      width: 75,
      height: 75,
      child: Stack(fit: StackFit.expand, children: [
        ClipRRect(
          borderRadius: BorderRadius.circular(10),
          child: FadeInImage.assetNetwork(
            placeholder: 'assets/images/common/lazy-1.png',
            image: info.coverPictureUrl ?? '',
            fit: BoxFit.cover,
          ),
        ),
        Center(
          child: Image.asset(
            'assets/images/icons/tiny_video.png',
            width: 22,
            height: 22,
            color: Colors.white,
          ),
        )
      ]),
    );
  }

  _songContent() {
    return Column(
      mainAxisAlignment: MainAxisAlignment.spaceBetween,
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Text(
              info.cnName ?? '',
              maxLines: 1,
              overflow: TextOverflow.ellipsis,
              style: TextStyle(fontSize: 16, color: AppColors.active),
            ),
            Text(
              info.enName ?? '',
              maxLines: 1,
              overflow: TextOverflow.ellipsis,
              style: TextStyle(fontSize: 12, color: AppColors.un3active),
            )
          ],
        ),
        Row(
          children: [
            SizedBox(
              width: 110,
              child: AvatarRoleName(
                  avatar: info.user?.coverPictureUrl ?? '',
                  nickname: info.user?.nickname ?? '',
                  type: info.user?.type ?? ''),
            ),
            Expanded(
                child: CommentLikeRead(
                    commentCount: info.commentCount ?? 0,
                    thumbUpCount: info.thumbUpCount ?? 0,
                    readCount: info.readCount ?? 0))
          ],
        )
      ],
    );
  }
}
